package logic

import (
	"context"
	"errors"

	"go-zero-mall/app/product/cmd/rpc/internal/svc"
	"go-zero-mall/app/product/cmd/rpc/pb"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type PmsCommentReplayInfoDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPmsCommentReplayInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PmsCommentReplayInfoDetailLogic {
	return &PmsCommentReplayInfoDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PmsCommentReplayInfoDetailLogic) PmsCommentReplayInfoDetail(in *pb.PmsCommentReplayInfoDetailReq) (*pb.PmsCommentReplayInfoDetailResp, error) {
	d, err := l.svcCtx.PmsCommentReplayModel.FindOne(l.ctx, in.Id)
	if err != nil {
		return nil, errors.New("查询错误")
	}
	var resp pb.PmsCommentReplayInfo
	copier.Copy(&resp, d)
	return &pb.PmsCommentReplayInfoDetailResp{Data: &resp}, nil
}
